﻿@{
    Layout = "";
}
<style>
    .my-drop-zone {
        border: dotted 3px lightgray;
    }

    .nv-file-over {
        border: dotted 3px red;
    }
    /* Default class applied to drop zones on over */
    .another-file-over-class {
        border: dotted 3px green;
    }

    html, body {
        height: 100%;
    }

    canvas {
        background-color: #f3f3f3;
        -webkit-box-shadow: 3px 3px 3px 0 #e3e3e3;
        -moz-box-shadow: 3px 3px 3px 0 #e3e3e3;
        box-shadow: 3px 3px 3px 0 #e3e3e3;
        border: 1px solid #c3c3c3;
        height: 100px;
        margin: 6px 0 0 6px;
    }

    .ngdialog.ngdialog-theme-plain .ngdialog-content {
        width: 50% !important;
    }
</style>
<div ng-controller="SpikeActivityUpdateController">
    <div class="container-fluid">
        <div class="row">
            <div class="col-md-12">
                <form name="formValidate" ng-submit="submitForm()" novalidate="" class="form-validate form-horizontal">
                    <!-- START panel-->
                    <div class="panel panel-default" ng-class="{ 'whirl standard': isLoading,'': isLoading }">
                        <div class="panel-body">
                            <fieldset class="b0">
                                <legend>{{Activity.Id == 0 || Activity.Id == null ? '添加限时抢购' : '修改限时抢购'}}</legend>
                            </fieldset>
                            <fieldset>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">活动名称</label>
                                    <div class="col-sm-4">
                                        <input type="text" name="name" required="" ng-model="Activity.Name" class="form-control" maxlength="50" />
                                        <span ng-show="validateInput('name', 'required')" class="text-danger">请输入活动名称</span>
                                    </div>
                                    <div class="col-sm-4">
                                        <h4 class="text-danger">*</h4>
                                    </div>
                                </div>
                            </fieldset>
                            <fieldset>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">副标题</label>
                                    <div class="col-sm-4">
                                        <input type="text" name="subTitle" required="" ng-model="Activity.SubTitle" class="form-control" maxlength="50" />
                                        <span ng-show="validateInput('subTitle', 'required')" class="text-danger">请输入副标题</span>
                                    </div>
                                    <div class="col-sm-4">
                                        <h4 class="text-danger">*</h4>
                                    </div>
                                </div>
                            </fieldset>
                            <fieldset>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">活动海报</label>
                                    <div class="col-sm-3">
                                        <div class="imgcrop-preview" uploader="uploader">
                                            <img ng-src="{{myCroppedImage}}" style="max-width: 100%; max-height: 100%" onerror="javascript: this.src = '/Content/img/default.png';" />
                                            <input id="fileInput" type="file" style="display: none;" nv-file-select="" uploader="uploader" />
                                        </div>
                                        <div>
                                            <div style="" class="progress progress-xs" ng-show="uploading">
                                                <div role="progressbar" ng-style="{ 'width': uploader.progress + '%' }" class="progress-bar"></div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-sm-1">
                                        <button type="button" class="mb-sm btn btn-info" ng-click="selectImage()">
                                            图片选择
                                        </button>
                                    </div>
                                    <div class="col-sm-4">
                                        <h4 class="text-danger">*&nbsp;&nbsp;建议尺寸：320×320 </h4>
                                    </div>
                                </div>
                            </fieldset>
                            <fieldset>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">开始时间</label>
                                    <div class="col-sm-4">
                                        <p class="input-group">
                                            <input ng-disabled="Activity.ActivityState=='进行中'||Activity.ActivityState=='已结束'" readonly="readonly" style="z-index: 0;" name="beginTime" required="" type="text" class="form-control" datetime-picker="yyyy-MM-dd HH:mm:ss" ng-model="Activity.BeginTime"
                                                   is-open="picker1.open" datepicker-options="datepickerOptions" />
                                            <span class="input-group-btn">
                                                <button type="button" class="btn btn-default" ng-click="openCalendar($event, 'picker1')" ng-disabled="Activity.ActivityState=='进行中'||Activity.ActivityState=='已结束'"><i class="fa fa-calendar"></i></button>
                                            </span>
                                        </p>
                                        <span ng-show="validateInput('beginTime', 'required')" class="text-danger">请输入开始时间</span>
                                    </div>
                                    <div class="col-sm-4">
                                        <h4 class="text-danger">*</h4>
                                    </div>
                                </div>
                            </fieldset>
                            <fieldset>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">结束时间</label>
                                    <div class="col-sm-4">
                                        <p class="input-group">
                                            <input ng-disabled="Activity.ActivityState=='已结束'" readonly="readonly" style="z-index: 0;" name="endTime" required="" type="text" class="form-control" datetime-picker="yyyy-MM-dd HH:mm:ss" ng-model="Activity.EndTime"
                                                   is-open="picker2.open" datepicker-options="datepickerOptions" />
                                            <span class="input-group-btn">
                                                <button type="button" class="btn btn-default" ng-click="openCalendar($event, 'picker2')" ng-disabled="Activity.ActivityState=='已结束'"><i class="fa fa-calendar"></i></button>
                                            </span>
                                        </p>
                                        <span ng-show="validateInput('endTime', 'required')" class="text-danger">请输入结束时间</span>
                                    </div>
                                    <div class="col-sm-4">
                                        <h4 class="text-danger">*</h4>
                                    </div>
                                </div>
                            </fieldset>
                            <fieldset>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">关联产品</label>
                                    <div class="col-sm-10">
                                        <div>
                                            <table ng-table="relatedProductsTableParams" class="table table-striped table-bproducted table-hover">
                                                <colgroup>
                                                    <col style="width: 10%" />
                                                    <col style="width: 10%" />
                                                    <col style="width: 10%" />
                                                    <col style="width: 10%" />
                                                    <col style="width: 10%" />
                                                    <col style="width: 8%" />
                                                    <col style="width: 8%" />
                                                    <col style="width: 8%" />
                                                    <col style="width: 8%" />
                                                </colgroup>
                                                <thead>
                                                    <tr>
                                                        <th class="text-center" colspan="2">产品名称</th>
                                                        <th class="text-center">市场价</th>
                                                        <th class="text-center">销售价</th>
                                                        <th class="text-center">可销库存</th>
                                                        <th class="text-center">抢购总量</th>
                                                        <th class="text-center">抢购价格(元)</th>
                                                        <th class="text-center">每人限购</th>
                                                        <th class="text-center"></th>
                                                    </tr>
                                                </thead>
                                                <tbody>
                                                    <tr ng-repeat="relationProduct in $data">
                                                        <td class="text-left" style="vertical-align: middle">
                                                            <img ng-src="{{ImgHostUrl+ relationProduct.ImgUrl}}" style="max-width: 100px; max-height: 100px; text-align: center;" onerror="javascript: this.src = '/Content/img/default.png';" />
                                                        </td>
                                                        <td class="text-left">{{relationProduct.Name}}</td>
                                                        <td class="text-center">{{relationProduct.MarketPrice.toFixed(2)}}</td>
                                                        <td class="text-center">{{relationProduct.SalePrice.toFixed(2)}}</td>
                                                        <td class="text-center">{{relationProduct.CanSaleStock}}</td>
                                                        <td class="text-center">
                                                            <input class="form-control" max="{{relationProduct.CanSaleStock}}" min="{{relationProduct.SpikeStock}}" name="stock{{$index}}" type="number" required="" ng-model="relationProduct.Stock" ng-pattern="/^[1-9]{1}[\d]*$/" maxlength="8">
                                                            <span ng-show="validateInput('stock' + $index, 'required')" class="text-danger">请输入抢购总量</span>
                                                            <span ng-show="validateInput('stock' + $index, 'pattern')" class="text-danger">请输入正确的抢购总量</span>
                                                        </td>
                                                        <td class="text-center">
                                                            <input class="form-control" name="price{{$index}}" required="" type="text" ng-model="relationProduct.Price" ng-pattern="/^(([0-9]|([1-9][0-9]{0,9}))((\.[0-9]{1,2})?))$/" maxlength="8">
                                                            <span ng-show="validateInput('price' + $index, 'required')" class="text-danger">请输入抢购价格</span>
                                                            <span ng-show="validateInput('price' + $index, 'pattern')" class="text-danger">请输入正确的抢购价格</span>
                                                        </td>
                                                        <td class="text-center">
                                                            <input class="form-control" name="limit{{$index}}" required="" type="number" ng-model="relationProduct.Limit" ng-pattern="/^[1-9]{1}[\d]*$/" maxlength="8">
                                                            <span ng-show="validateInput('limit' + $index, 'required')" class="text-danger">请输入每人限购数量</span>
                                                            <span ng-show="validateInput('limit' + $index, 'pattern')" class="text-danger">请输入正确的每人限抢</span>
                                                        </td>
                                                        <td class="text-center">
                                                            <button type="button" class="btn btn-warning" ng-click="delectThisData(relationProduct.ProductSku)">删除</button>
                                                        </td>
                                                    </tr>
                                                </tbody>
                                            </table>
                                            <span ng-show="SpikeActivityInfoList.length == 0" class="text-danger">请选择产品</span>
                                            <br />
                                            <div class="text-right">
                                                <button type="button" class="btn btn-info" ng-click="relationProductSelectInit()">选择关联产品</button>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </fieldset>
                            <fieldset>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">分享标题</label>
                                    <div class="col-sm-3">
                                        <input placeholder="分享标题默认为：活动名称" class="form-control" maxlength="20" ng-model="Activity.ShareTitle">
                                    </div>
                                </div>
                            </fieldset>
                            <fieldset>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">分享内容</label>
                                    <div class="col-sm-3">
                                        <textarea placeholder="分享内容默认为活动副标题" class="form-control" maxlength="50" ng-model="Activity.ShareContent"></textarea>
                                    </div>
                                </div>
                            </fieldset>
                        </div>
                        <div class="panel-footer text-right">
                            <button type="button" class="btn btn-warning" ng-click="cancel()">返回列表</button>
                            <button type="submit" class="btn btn-primary">保存</button>
                        </div>
                    </div>
                    <!-- END panel-->
                </form>
            </div>
        </div>
    </div>
</div>
<script type="text/ng-template" id="productSelectDialogId">
    <div class="ngdialog-message">
        <div class="panel panel-default">
            <div class="panel-heading">
                <div class="form-inline ng-pristine ng-valid">
                    <div class="form-group">
                        <input placeholder="关键字" class="form-control" type="text" ng-model="ProductSelectModel.Keywords">
                        <select ng-options="m.Id as m.CategoryName for m in FirstCategoryList" ng-model="ProductSelectModel.FirstCategoryId" ng-change="GetSecondCategory()" class="form-control">
                            <option value="">请选择一级分类</option>
                        </select>
                        <select ng-options="m.Id as m.CategoryName for m in SecondCategoryList" ng-model="ProductSelectModel.SecondCategoryId" class="form-control">
                            <option value="">请选择二级分类</option>
                        </select>
                        <button type="submit" class="btn btn-labeled btn-primary" ng-click="tableParams.$params.page = 1;tableParams.reload()">
                            <span class="btn-label">
                                <em class="fa fa-search"></em>
                            </span>搜索
                        </button>
                    </div>
                </div>
            </div>
            <table ng-table="tableParams" class="table table-striped table-bproducted table-hover">
                <colgroup>
                    <col style="width: 10%" />
                    <col style="width: 15%" />
                    <col style="width: 20%" />
                    <col style="width: 15%" />
                    <col style="width: 15%" />
                    <col style="width: 15%" />
                    <col style="width: 10%" />
                </colgroup>
                <thead>
                    <tr>
                        <th class="text-center"></th>
                        <th class="text-center" colspan="2">产品名称</th>
                        <th class="text-center">市场价</th>
                        <th class="text-center">销售价</th>
                        <th class="text-center">可销库存</th>
                    </tr>
                </thead>
                <tr ng-repeat="product in $data">
                    <td>
                        <div class="checkbox c-checkbox">
                            <label>
                                <input type="checkbox" ng-click="checkProduct($event,product)" ng-checked="isChecked(product.Sku)" />
                                <span class="fa fa-check"></span>
                            </label>
                        </div>
                    </td>
                    <td>
                        <img ng-src="{{ImgHostUrl+ product.ImgUrl}}" style="max-width: 100px; max-height: 100px;text-align:center;margin-left:5px" onerror="javascript: this.src = '/Content/img/default.png';" />
                    </td>
                    <td class="text-left"> {{product.Name}}</td>
                    <td class="text-center">{{product.MarketPrice.toFixed(2)}}</td>
                    <td class="text-center">{{product.Price.toFixed(2)}}</td>
                    <td class="text-center">{{product.TotalStock}}</td>
                </tr>
            </table>
            <div class="panel-footer">
                <div class="form-inline ng-pristine ng-valid">
                    <div class="form-group ">已选择产品：</div>
                    <div class="form-group " ng-repeat="select in SpikeActivityInfoList">
                        <a href="" class="mr-sm label label-primary" ng-click="SpikeActivityInfoList.splice($index, 1);" title="{{select.Name}}">
                            {{select.Name}}
                        </a>
                    </div>
                </div>
            </div>
            <div class="panel-footer text-right">
                <button type="button" class="btn btn-primary" ng-click="closeDialog()">
                    关闭
                </button>
            </div>
        </div>
    </div>
</script>
<script type="text/javascript">
    App.controller('SpikeActivityUpdateController', ["$scope", "$state", "$http", "$stateParams", "Notify", 'ngTableParams', 'ngTableDataService', 'FileUploader', 'ngDialog', '$filter', '$rootScope',
        function ($scope, $state, $http, $stateParams, Notify, ngTableParams, ngTableDataService, FileUploader, ngDialog, $filter, $rootScope) {
            'use strict';
            $scope.submitted = false;
            $scope.isLoading = true;
            $scope.Activity = {};
            $scope.isLoadingProduct = true;
            $scope.SpikeActivityInfoList = [];
            $scope.ProductSelectModel = {};
            //已选择产品
            $scope.validateInput = function (name, type) {
                var input = $scope.formValidate[name];
                return (input.$dirty || $scope.submitted) && input.$error[type];
            };

            $scope.selectImage = function () {
                $("#fileInput").click();
            }


            //数据初始化
            $http.post("/Activity/SpikeEdit", { Id: $stateParams.Id }).then(function (response) {
                //console.log(response);
                if (response.data && response.data != '') {
                    $scope.Activity = response.data.Activity;
                    if ($scope.Activity.Id == 0) {
                        $scope.Activity.ActivityState = '';
                    }
                    if (response.data.SpikeActivityInfoList && response.data.SpikeActivityInfoList != '') {

                        $scope.SpikeActivityInfoList = response.data.SpikeActivityInfoList;
                        $scope.relatedProductsTableParams.reload();
                    }
                    if (response.data.Activity.HeadPicUrl && response.data.Activity.HeadPicUrl != '') {
                        $scope.myCroppedImage = $rootScope.ImgHostUrl + angular.copy(response.data.Activity.HeadPicUrl);
                    }
                    $scope.CategoryList = response.data.CategoryList;
                    if (!$scope.CategoryList) {
                        $scope.CategoryList = [];
                    }

                    //获取一级分类
                    $scope.FirstCategoryList = $filter('filter')($scope.CategoryList, function (item) { return item.ParentId === 0; });

                    //获取二级分类
                    $scope.GetSecondCategory = function () {
                        $scope.SecondCategoryList = $filter('filter')($scope.CategoryList, function (item) { return item.ParentId === $scope.ProductSelectModel.FirstCategoryId; });
                    }
                }
                $scope.isLoading = false;
            });

            // 提交
            $scope.submitForm = function () {
                $scope.isLoading = true;
                $scope.submitted = true;
                if ($scope.formValidate.$valid) {
                    if ($scope.SpikeActivityInfoList == undefined || $scope.SpikeActivityInfoList.length === 0) {
                        Notify.alert("请选择产品", { status: 'warning' });
                        $scope.isLoading = false;
                        return false;
                    }
                    if ($scope.Activity.HeadPicUrl == undefined || $scope.Activity.HeadPicUrl === "") {
                        Notify.alert("请选择活动海报", { status: 'warning' });
                        $scope.isLoading = false;
                        return false;
                    }
                    var t1 = new Date($scope.Activity.BeginTime);
                    var t2 = new Date($scope.Activity.EndTime);
                    var time1 = t1.getFullYear() + "/" + (t1.getMonth()+1) + "/" + t1.getDate();
                    var time2 = t2.getFullYear() + "/" + (t2.getMonth()+1) + "/" + t2.getDate();
                    if (time1 != time2) {
                        Notify.alert("秒杀日期应为同一天", { status: 'warning' });
                        $scope.isLoading = false;
                        return false;
                    }
                    $http.post("/Activity/SpikeEditSubmit", { Activity: $scope.Activity, SpikeActivityProductSelectedList: $scope.SpikeActivityInfoList }).then(function (returnData) {
                        if (returnData.data.isSuccess) {
                            Notify.alert('操作成功!', { status: 'success', timeout: 1000 });
                            $state.go("app.spikeActivity");
                        } else {
                            Notify.alert(returnData.data.msg, { status: 'warning', timeout: 1000 });
                        }
                        $scope.isLoading = false;
                    });
                } else {
                    $scope.isLoading = false;
                    return false;
                }
            };

            //返回列表
            $scope.cancel = function () {
                $state.go("app.spikeActivity");
            }

            // 日期插件
            $scope.picker1 = {
                date: new Date()
            };

            $scope.picker2 = {
                date: new Date()
            };

            $scope.datepickerOptions = {
                showWeeks: false,
                startingDay: 1,
                dateDisabled: function (data) {
                    //return (data.mode === 'day' && (new Date().toDateString() == data.date.toDateString()));
                }
            }

            $scope.openCalendar = function (e, picker) {
                $scope[picker].open = true;
            };

            //关闭产品选择弹框加载已选产品数据
            $scope.closeDialog = function () {
                $scope.relatedProductsTableParams.reload();
                ngDialog.closeAll();
            }
            //删除已经选择的产品
            $scope.delectThisData = function (sku) {
                var tempData = [];
                $scope.SpikeActivityInfoList.forEach(function (item) {
                    if (item.ProductSku != sku) {
                        tempData.push(item);
                    }
                });
                $scope.SpikeActivityInfoList = tempData;
                $scope.relatedProductsTableParams.reload();
            }


            //已选择产品分页显示
            $scope.relatedProductsTableParams = new ngTableParams({
                page: 1,
                count: 5,
                sorting: {
                    Id: 'desc'     // 初始化排序
                }
            }, {
                getData: function ($defer, params) {
                    $scope.isLoadingProduct = true;
                    var requestParams = {
                        Skip: (params.page() - 1) * params.count(),
                        Take: params.count()
                    };
                    params.total($scope.SpikeActivityInfoList.length);
                    var tempActivityInfoList = [];
                    var starNum = 0;
                    $scope.SpikeActivityInfoList.forEach(function (item) {

                        var dataNum = starNum - requestParams.Skip;
                        if (dataNum >= 0 && dataNum < requestParams.Take) {
                            tempActivityInfoList.push(item);
                        }
                        starNum = starNum + 1;
                    });
                    $defer.resolve(tempActivityInfoList);
                    $scope.isLoadingProduct = false;
                }
            });



            //-----------产品选择相关
            //关联产品选择
            $scope.relationProductSelectInit = function () {
                $scope.ProductSelect = {};
                ngDialog.openConfirm({
                    template: 'productSelectDialogId',
                    className: 'ngdialog-theme-plain',
                    scope: $scope
                }).then(function (value) {
                }, function (reason) {
                }
                );
            }

            //-----------产品选择相关
            $scope.tableParams = new ngTableParams({
                page: 1,
                count: 10,
                sorting: {
                }
            }, {
                getData: function ($defer, params) {
                    $scope.isLoadingProduct = true;
                    var requestParams = {
                        Skip: (params.page() - 1) * params.count(),
                        Take: params.count(),
                        Keywords: $scope.ProductSelectModel.Keywords,
                        FirstCategoryIdParm: $scope.ProductSelectModel.FirstCategoryId,
                        SecondCategoryIdParm: $scope.ProductSelectModel.SecondCategoryId
                    };
                    $http.post('/Activity/ProductSelect', ngTableDataService.getServerSideParams(params.orderBy().toString(), params, requestParams))
                        .success(function (data, status) {
                            params.total(data.Total);
                            $defer.resolve(data.Results);

                            $scope.isLoadingProduct = false;
                        });
                }
            });


            //判断产品是否已选择
            $scope.isChecked = function (sku) {
                var result = false;
                angular.forEach($scope.SpikeActivityInfoList, function (value, key) {
                    if (sku == value.ProductSku) {
                        result = true;
                        return false;
                    }
                });
                return result;
            }

            $scope.checkProduct = function ($event, productSpec) {
                if ($event.target.checked) {
                    $scope.SpikeActivityInfoList.push(
                    {
                        Name: productSpec.Name,
                        SalePrice: productSpec.Price,
                        MarketPrice: productSpec.MarketPrice,
                        CanSaleStock: productSpec.TotalStock,
                        ProductSku: productSpec.Sku,
                        ImgUrl: productSpec.ImgUrl
                    });
                } else {
                    var currentSelected = $filter('filter')($scope.SpikeActivityInfoList, function (item) { return item.ProductSku == productSpec.Sku; });
                    if (currentSelected && currentSelected.length > 0) {
                        $scope.SpikeActivityInfoList.splice($scope.SpikeActivityInfoList.indexOf(currentSelected[0]), 1);
                    }
                }
            }

            //-------------图片选择相关
            var handleFileSelect = function (evt) {
                var file = $scope.uploadSelectFile = evt.currentTarget.files[0];
                if (!evt.currentTarget.files[0] || ! /image\/\w+/.test(evt.currentTarget.files[0].type)) {
                    Notify.alert('请选择图像文件', { status: 'warning' });
                    return false;
                }
                if (file.size > 1 * 1024 * 1024) {
                    Notify.alert('图片大小不能大于1MB', { status: 'warning', timeout: 3000 });
                    $scope.uploadSelectFile = null;
                    return false;
                }
                var reader = new FileReader();
                reader.onload = function (evt) {
                    $scope.$apply(function ($scope) {
                        $scope.myCroppedImage = evt.target.result;
                    });
                };
                if (file)
                    reader.readAsDataURL(file);
            };

            angular.element(document.querySelector('#fileInput')).on('change', handleFileSelect);
            var uploader = $scope.uploader = new FileUploader({
                
                url: $scope.ImgUploadUrl + '?PlatForm=wsd&Path=ActivitySpike'
            });
            uploader.filters.push({
                name: 'customFilter',
                fn: function (item /*{File|FileLikeObject}*/, options) {
                    return this.queue.length < 10;
                }
            });

            // CALLBACKS

            uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
                  console.info('onWhenAddingFileFailed', item, filter, options);
            };
            uploader.onAfterAddingFile = function (fileItem) {
                if ($scope.uploadSelectFile && /image\/\w+/.test($scope.uploadSelectFile.type)) {
                    $scope.uploading = true;
                    fileItem.upload();
                }
                    console.info('onAfterAddingFile', fileItem);
            };
            uploader.onAfterAddingAll = function (addedFileItems) {
                   console.info('onAfterAddingAll', addedFileItems);
            };
            uploader.onBeforeUploadItem = function (item) {
                 console.info('onBeforeUploadItem', item);

            };
            uploader.onProgressItem = function (fileItem, progress) {
                 console.info('onProgressItem', fileItem, progress);
            };
            uploader.onProgressAll = function (progress) {
                //  console.info('onProgressAll', progress);
            };
            uploader.onSuccessItem = function (fileItem, response, status, headers) {
                $scope.Activity.HeadPicUrl = response[0];
                $("#fileInput").val("");
                  console.info('onSuccessItem', fileItem, response, status, headers);
            };
            uploader.onErrorItem = function (fileItem, response, status, headers) {
                  console.info('onErrorItem', fileItem, response, status, headers);
            };
            uploader.onCancelItem = function (fileItem, response, status, headers) {
                 console.info('onCancelItem', fileItem, response, status, headers);
            };
            uploader.onCompleteItem = function (fileItem, response, status, headers) {
                  console.info('onCompleteItem', fileItem, response, status, headers);
            };
            uploader.onCompleteAll = function () {
                $scope.uploading = false;
            };
        }]);
</script>
